<template>
  <div>
    <el-table
      :data="roleList"
      style="width: 100%; margin-bottom: 20px"
      row-key="id"
      border
      default-expand-all
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
    >
      <el-table-column prop="id" label="角色编号"></el-table-column>
      <el-table-column prop="rolename" label="角色名称"></el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scoped">
          <div>
            <el-button type="success" v-if="scoped.row.status == 1"
              >启 用</el-button
            >
            <el-button type="info" v-else>禁 用</el-button>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scoped">
          <div>
            <el-button type="primary" @click="update(scoped.row.id)">编 辑</el-button>
           <v-del @del="del(scoped.row.id)"></v-del>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {roledeLete} from "../../../request/api.js"
import {mapActions,mapGetters} from "vuex"
import { successAlert, warningAlert } from "../../../utils/alert.js";
export default {
  data() {
    return {
    
    };
  },
  computed:{
    ...mapGetters({
      roleList:"role/list" 
    })
  },
  methods: {
    ...mapActions({
    cc:"role/asyncChangeList"
    }),
    //点击编辑
    update(id){
      this.$emit('fn1',id);
    },
    //点击删除
   del(id){
roledeLete({id:id}).then(res=>{
  if(res.data.code==200){
    successAlert(res.data.msg)
      this.cc()
  }else{
    warningAlert(res.data.msg)
  }
})
   }
  },
  mounted(){
    this.cc()
  },
};
</script>

<style lang="scss" scoped>
</style>